{template "header.html"}

<div class="note note-danger">
    <p><a href="javascript:dr_update_cache();">{dr_lang('更改数据之后需要更新缓存之后才能生效')}</a></p>
</div>
<form action="" class="form-horizontal" method="post" name="myform" id="myform">
    {$form}
    <div class="portlet bordered light myfbody">
        <div class="portlet-title tabbable-line">
            <ul class="nav nav-tabs" style="float:left;">
                <li class="{if $page==0}active{/if}">
                    <a href="#tab_0" data-toggle="tab" onclick="$('#dr_page').val('0')"> <i class="fa fa-cog"></i> {dr_lang('插件设置')} </a>
                </li>
            </ul>
        </div>
        <div class="portlet-body">
            <div class="tab-content">
                <div class="tab-pane {if $page==0}active{/if}" id="tab_0">
                    <div class="form-body">


                        <div class="form-group">
                            <label class="col-md-2 control-label">{dr_lang('后台界面翻译')}</label>
                            <div class="col-md-9">
                                <input type="checkbox" name="data[use]" value="1" {if $data['use']}checked{/if} data-on-text="{dr_lang('已开启')}" data-off-text="{dr_lang('已关闭')}" data-on-color="success" data-off-color="danger" class="make-switch" data-size="small">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">内容模块按钮</label>
                            <div class="col-md-9">

                                <div class="mt-checkbox-inline">
                                    {loop $module $t}
                                    <label class="mt-checkbox mt-checkbox-outline">
                                        <input type="checkbox" name="data[module][]" {if dr_in_array($t.dirname, $data.module)}checked{/if} value="{$t.dirname}"> {$t.name}
                                        <span></span>
                                    </label>
                                    {/loop}
                                </div>


                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">AppId</label>
                            <div class="col-md-9">
                                <input class="form-control input-xlarge" type="text" name="data[appid]" value="{$data['appid']}" >
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label">AppSecret</label>
                            <div class="col-md-9">
                                <input class="form-control input-xlarge" type="text" name="data[appsecret]" value="{$data['appsecret']}" >
                            </div>
                        </div>



                        <div class="form-group">
                            <label class="col-md-2 control-label">查看常见语言代码对照表</label>
                            <div class="col-md-9" style="padding-top: 8px">
                                <a href="https://fanyi-api.baidu.com/product/113" target="_blank">https://fanyi-api.baidu.com/product/113</a>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">翻译文字测试</label>
                            <div class="col-md-9">
                                <label><input type="text" name="post[text]" value="我是中国人" class="form-control"></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">翻译语言设置</label>
                            <div class="col-md-9">
                                <label><input type="text" name="post[lang]" value="en" class="form-control"></label>
                                <label><button type="button" onclick="dr_test2()" class="btn btn green"> 测试翻译内容</button></label>
                                <label><button type="button" onclick="dr_test3()" class="btn btn red"> 错误代码解释</button></label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-md-2 control-label">翻译结果</label>
                            <div class="col-md-9" style="padding-top: 8px" id="dr_sync_html">

                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="portlet-body form myfooter">
        <div class="form-actions text-center">
            <button type="button" onclick="dr_ajax_submit('{dr_now_url()}&page='+$('#dr_page').val(), 'myform', '2000')" class="btn green"> <i class="fa fa-save"></i> {dr_lang('保存')}</button>
        </div>
    </div>
</form>


<script>
    function dr_test3() {
        layer.open({
            type: 1,
            title: "错误代码",
            fix:true,
            //scrollbar: false,
            shadeClose: true,
            shade: 0,
            area: ['80%', '70%'],
            content: "<div style='padding: 10px; text-align: center'><img src='{dr_url(APP_DIR.'/config/error_index')}'></div>"
        });
    }
    function dr_test2() {
        $('#dr_sync_html').html('正在请求百度...');
        $.ajax({
            type: "POST",
            dataType: "json",
            data: $("#myform").serialize(),
            url: "{dr_url(APP_DIR.'/config/lang_index')}",
            success: function(json) {
                if (json.code) {
                    $('#dr_sync_html').html('<font color="green">'+json.msg+'</font>');
                } else {
                    $('#dr_sync_html').html('<font color="red">'+json.msg+'</font>');
                }
            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                $('#dr_sync_html').html('<font color="red">发生异常：'+HttpRequest.responseText+'</font>');
            }
        });
    }

</script>

{template "footer.html"}